package com.atguigu.product.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

////import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.atguigu.product.entity.CategoryBrandRelationEntity;
import com.atguigu.product.service.CategoryBrandRelationService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;



/**
 * 品牌分类关联
 *
 * @author dengjia
 * @email ${email}
 * @date 2022-01-05 12:03:58
 */
@RestController
@RequestMapping("product/categorybrandrelation")
public class CategoryBrandRelationController {
    @Autowired
    private CategoryBrandRelationService CategoryBrandRelationService;

    /**
     * 获取当前品牌 关联 分类的信息
     */
    @GetMapping("/catelog/list")
    //////@RequiresPermissions("product:categorybrandrelation:list")
    public R list(@RequestParam("brandId") Long brandId){
        List<CategoryBrandRelationEntity> list  = CategoryBrandRelationService.findById(brandId);
        return R.ok().put("data", list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    ////@RequiresPermissions("product:categorybrandrelation:info")
    public R info(@PathVariable("id") Long id){
		CategoryBrandRelationEntity CategoryBrandRelation = CategoryBrandRelationService.getById(id);

        return R.ok().put("CategoryBrandRelation", CategoryBrandRelation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   // //@RequiresPermissions("product:categorybrandrelation:save")
    public R save(@RequestBody CategoryBrandRelationEntity CategoryBrandRelation){
		CategoryBrandRelationService.saveCategoryBrandRelation(CategoryBrandRelation);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    ////@RequiresPermissions("product:categorybrandrelation:update")
    public R update(@RequestBody CategoryBrandRelationEntity CategoryBrandRelation){
		CategoryBrandRelationService.updateById(CategoryBrandRelation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    ////@RequiresPermissions("product:categorybrandrelation:delete")
    public R delete(@RequestBody Long[] ids){
		CategoryBrandRelationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
